package com.dream.entity;

import com.dream.common.utils.pickutils.NumberUtil;
import org.springframework.util.StringUtils;


public class PickerOverViewBean {
    public String pickUserId;
    public String pickUserName;
    public String pickUserHeadUrl;
    public int sendNumber;
    public String sendMoney;
    public int pickNumber;
    public String pickMoney;
    public String senderProfitMoney;
    public String rewardMoney;
    public String payMoney;
    public String profitMoney;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PickerOverViewBean picker = (PickerOverViewBean) o;
        return pickUserId.equals(picker.pickUserId);
    }

    public PickerOverViewBean getFormatPickerOverViewBean(PickerOverViewBean picker) {
        if (StringUtils.isEmpty(picker.sendMoney) || picker.sendMoney.equals("0")) {
            picker.sendMoney = "0.00";
        } else {
            picker.sendMoney = NumberUtil.divide(picker.sendMoney, "1", 2);
        }
        if (StringUtils.isEmpty(picker.pickMoney) || picker.pickMoney.equals("0")) {
            picker.pickMoney = "0.00";
        } else {
            picker.pickMoney = NumberUtil.divide(picker.pickMoney, "1", 2);
        }
        if (StringUtils.isEmpty(picker.rewardMoney) || picker.rewardMoney.equals("0")) {
            picker.rewardMoney = "0.00";
        } else {
            picker.rewardMoney = NumberUtil.divide(picker.rewardMoney, "1", 2);
        }
        if (StringUtils.isEmpty(picker.payMoney) || picker.payMoney.equals("0")) {
            picker.payMoney = "0.00";
        } else {
            picker.payMoney = NumberUtil.divide(picker.payMoney, "1", 2);
        }
        if (StringUtils.isEmpty(picker.payMoney) || picker.payMoney.equals("0")) {
            picker.payMoney = "0.00";
        } else {
            picker.payMoney = NumberUtil.divide(picker.payMoney, "1", 2);
        }
        if (StringUtils.isEmpty(picker.senderProfitMoney) || picker.senderProfitMoney.equals("0")) {
            picker.senderProfitMoney = "0.00";
        } else {
            picker.senderProfitMoney = NumberUtil.divide(picker.senderProfitMoney, "1", 2);
        }
        picker.profitMoney = NumberUtil.subtract(NumberUtil.add(NumberUtil.add(pickMoney, rewardMoney), senderProfitMoney), NumberUtil.add(sendMoney, payMoney));
        return picker;
    }
}
